#!/usr/bin/python
# -*- coding: utf-8 -*-
#
#
# AFCP webapp URL mappings.
#
# Created on 2009-04-20.
# $Id: mail.py 300 2009-04-20 14:56:43Z Guolin $

from google.appengine.api import mail
from afcpweb.apps.afcp.models import get_on_inscription_activity

def send_mail( uid, user_address ):

    if not mail.is_email_valid(user_address):
      # prompt user to enter a valid address
		return "Error of invalid address : %s " % user_address
    else:
		message = mail.EmailMessage( sender="AFCParisTech@gmail.com",
									 subject="Confirm your Inscription")
		message.to = user_address
		activity = get_on_inscription_activity()
		
		message.body  = """ Thank you for yout inscription! 
							Please remember your confirm code :%s 
							Activity : %s 
							Subject  : %s
							Address  : %s
							Date     : %s
							""" % (uid, activity.name, activity.subject, activity.address, activity.date ) 
		message.send()		
		return "Success to send email to %s" %  user_address